package com.example.demo.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JSONUtil {
    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        Person person = new Person();
        person.setAge(18);
        person.setName("kzf");
        person.setHeight(120);
        String jsonstr = mapper.writeValueAsString(person);
        System.out.println(jsonstr);
        Person person2 = mapper.readValue(jsonstr, Person.class);
        System.out.println(person2.getName()+","+person2.getAge()+","+person2.getHeight());
    }
}
